package com.sfzy.controller;

import com.sfzy.service.MyConsultService;
import com.sfzy.entity.MyConsult;
import com.sfzy.util.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("myConsult")
public class MyConsultController {
    @Autowired
    private MyConsultService myConsultService;

    @PostMapping
    public R add(@RequestBody MyConsult myConsult) {
        return R.ok(myConsultService.addMyConsult(myConsult));
    }

    @PutMapping
    public R update(@RequestBody MyConsult myConsult) {
        return R.ok(myConsultService.updateMyConsult(myConsult));
    }

    @DeleteMapping("{id}")
    public R delete(@PathVariable("id") int id) {
        return R.ok(myConsultService.deleteMyConsult(id));
    }

    @GetMapping("{id}")
    public R getMyConsult(@PathVariable("id") int id) {
        return R.ok(myConsultService.getMyConsult(id));
    }

    @GetMapping("page")
    public R getMyConsultPage(MyConsult myConsult,
                              @RequestParam(defaultValue = "1",required = false) int pageNum,
                              @RequestParam(defaultValue = "6",required = false) int pageSize) {
        return R.ok(myConsultService.listMyConsultByPage(myConsult,pageNum,pageSize));
    }
}
